/*
 * Copyright 2017 JessYan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.yiqi.news.mvp.model.api.service

import com.yiqi.news.entity.*
import io.reactivex.Observable

import retrofit2.Retrofit
import retrofit2.http.*

/**
 * ================================================
 * 展示 [Retrofit.create] 中需要传入的 ApiService 的使用方式
 * 存放关于用户的一些 API
 *
 *
 * Created by JessYan on 08/05/2016 12:05
 * [Contact me](mailto:jess.yan.effort@gmail.com)
 * [Follow me](https://github.com/JessYanCoding)
 * ================================================
 */
interface NewsService {


    /**
     * 获取新闻列表
     * */
    @POST("api/material/listMaterial")

    fun newsList(@Query("page") page: Int, @Query("limit") limit: Int, @Query("materialType") materialType: Int, @Query("labelCode") labelCode: String): Observable<BaseResponse<Page<News>>>


    /**
     * 搜索新闻动态
     * */
    @POST("api/material/listMaterial")
    fun searchNewsList(@Query("page") page: Int, @Query("limit") limit: Int, @Query("searchKey") keywords: String, @Query("materialType") materialType: Int = 1): Observable<BaseResponse<Page<News>>>

    /**
     * 获取新闻详情
     * */
    @GET("api/material/infoMaterial/{newsId}/{userId}")

    fun newsDetail(@Path("newsId") page: String,@Path("userId") userId: String): Observable<BaseResponse<NewsDetail>>

    /**
     * 新闻评价
     * */
    @POST("api/material/saveComment")

    fun commentNews(@Body map: HashMap<String, Any?>): Observable<BaseResponse<NewsDetail>>

    /**
     * 新闻点赞
     * */
    @POST("api/material/saveZan")

    fun likeNews(@Body map: HashMap<String, Any?>): Observable<BaseResponse<NewsDetail>>


    /**
     * 新闻收藏
     * */
    @POST("api/user/updateUserMaterials")

    fun collectionNews(@Body map: HashMap<String, Any?>): Observable<BaseResponse<NewsDetail>>

    /**
     * 搜索关键词
     *
     * */
    @GET("client/hotkey/list")
    fun searchKeywords(): Observable<BaseResponse<List<HotVO>>>

    /**
     * 新闻收藏
     * */
    @POST("api/user/updateUserMaterials")

    fun getReply(@Body map: HashMap<String, Any?>): Observable<BaseResponse<List<ReplyVO>>>

    /**
     * 签到
     * */
    @POST("api/user/sign")

    fun signIn(): Observable<BaseResponse<User>>

    /**
     * 签到
     * */
    @POST("api/user/listSign")

    fun signHistory(): Observable<BaseResponse<List<SignHistoryVO>>>
}